package com.wgo.precise.client.ui.view.projecttree;

import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;

import com.wgo.precise.client.ui.controller.RequirementPlugin;
import com.wgo.precise.client.ui.model.NodeChild;
import com.wgo.precise.client.ui.model.facade.INodeParent;


/**
 * @author petterei
 * @version $Id: DeleteAction.java,v 1.1 2006-01-23 19:58:38 petterei Exp $
 */
public class DeleteAction extends CrudAction<NodeChild> {

	public DeleteAction(NodeChild item) {
        super("Delete " + item.getText(), item, PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));
    }
    @SuppressWarnings("unchecked")
	@Override
    public void run() {
        if ( MessageDialog.openConfirm(RequirementPlugin.getInstance().getWorkbench().getDisplay().getActiveShell(),"Really delete?", "Do you want to delete " + getItem().getText() ) ) {
//        	NodeParent parent = ((NodeChild)getItem()).getParent(); //TODO : notify parent update?
        	INodeParent parent = getItem().getParent();
        	getItem().setParent(null);
        	RequirementPlugin.getInstance().getPreciseSubject().notifyModelItemDeleted(getItem(), parent);
        }
        super.run();
    }
}

/**
 * 
 * Changelog:
 * 
 * $Log: DeleteAction.java,v $
 * Revision 1.1  2006-01-23 19:58:38  petterei
 * initial commit for client, fitting the alternative session implementation
 *
 * Revision 1.7  2005-12-14 20:27:21  petterei
 * added custom images
 *
 * Revision 1.6  2005-12-14 08:22:04  petterei
 * -refactored: new categories inherit propertysets from parent category, requirements-propertysets is only retrieved from parent category (before: no "physical" category inheritance, but requirement got propertysets from all categoryparents)
 * -cleaned up some code and configfiles, minor refactoring
 *
 * Revision 1.5  2005-12-13 12:10:54  petterei
 * refactorin + bugfix
 *
 * Revision 1.4  2005-12-07 18:51:44  petterei
 * fixed gui to modify "relationship"-fields that maps to other domain-models
 *
 * Revision 1.3  2005-12-05 04:16:41  petterei
 * *** empty log message ***
 *
 * Revision 1.2  2005-11-21 15:40:45  petterei
 * *** empty log message ***
 *
 * Revision 1.1  2005/09/27 21:06:18  petterei
 * *** empty log message ***
 *
 * Revision 1.4  2005/09/27 17:06:19  petterei
 * *** empty log message ***
 *
 * Revision 1.3  2005/08/23 06:40:47  peide3
 * *** empty log message ***
 *
 * Revision 1.1  2005/07/31 22:55:09  petterei
 * initial commit
 *
 * Revision 1.2  2005/07/20 08:48:40  peide3
 * updated and implemented more functionality
 *
 * Revision 1.1  2005/07/20 06:06:39  peide3
 * implemented Eclipse-IActions
 *
 */
 